home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Files / XTND 1.3.6 / Application Examples / PascalSource / XTEStyleSample.h < prev    next >
Encoding:
Text File  |  1991-06-12  |  10.6 KB  |  266 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Styled TextEdit Sample Application
  6. #
  7. #    TEStyleSample
  8. #
  9. #    TEStyleSample.h    -    Rez Source
  10. #
  11. #    Copyright © 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    1.0                        10/89
  15. #
  16. #    Components:    TEStyleSample.p            October    1, 1989
  17. #                TEStyleSampleGlue.a        October    1, 1989
  18. #                TEStyleSample.r            October    1, 1989
  19. #                TEStyleSample.h            October    1, 1989
  20. #                PTEStyleSample.make        October    1, 1989
  21. #
  22. #    TEStyleSample is an example application that demonstrates how 
  23. #    to initialize the commonly used toolbox managers, operate 
  24. #    successfully under MultiFinder, handle desk accessories and 
  25. #    create, grow, and zoom windows. Both styled and fundamental TextEdit 
  26. #    toolbox calls and TextEdit autoscroll are demonstrated. It 
  27. #    also shows how to create and maintain scrollbar controls as well
  28. #    as implementing a basic printing loop.
  29. #
  30. #    It does not by any means demonstrate all the techniques you 
  31. #    need for a large application. In particular, TEStyleSample does not 
  32. #    cover exception handling, multiple windows/documents, 
  33. #    sophisticated memory management, or undo. All of 
  34. #    these are vital parts of a normal full-sized application.
  35. #
  36. #    This application is an example of the form of a Macintosh 
  37. #    application; it is NOT a template. It is NOT intended to be 
  38. #    used as a foundation for the next world-class, best-selling, 
  39. #    600K application. A stick figure drawing of the human body may 
  40. #    be a good example of the form for a painting, but that does not 
  41. #    mean it should be used as the basis for the next Mona Lisa.
  42. #
  43. #    We recommend that you review this program, TESample or Sample before 
  44. #    beginning a new application. TESample is a simpler version of TEStyleSample
  45. #    without styles and Sample is a simple app. which doesn’t 
  46. #    use TextEdit or the Control Manager.
  47. #
  48. ------------------------------------------------------------------------------*/
  49.  
  50. /*    These #defines correspond to values in the Pascal source code.
  51.     TEStyleSample.c and TEStyleSample.r include this file. */
  52.  
  53. /*    Determining an application's minimum size to request from MultiFinder depends
  54.     on many things, each of which can be unique to an application's function,
  55.     the anticipated environment, the developer's attitude of what constitutes
  56.     reasonable functionality and performance, etc. Here is a list of some things to
  57.     consider when determining the minimum size (and preferred size) for your
  58.     application. The list is pretty much in order of importance, but by no means
  59.     complete.
  60.     
  61.     1.    What is the minimum size needed to give almost 100 percent assurance
  62.         that the application won't crash because it ran out of memory? This
  63.         includes not only things that you do have direct control over such as
  64.         checking for NIL handles and pointers, but also things that some
  65.         feel are not so much under their control such as QuickDraw and the
  66.         Segment Loader.
  67.         
  68.     2.    What kind of performance can a user expect from the application when
  69.         it is running in the minimum memory configuration? Performance includes
  70.         not only speed in handling data, but also things like how many documents
  71.         can be opened, etc.
  72.         
  73.     3.    What are the typical sizes of scraps is [a boy dog] that a user might
  74.         wish to work with when lauching or switching to your application? If
  75.         the amount of memory is too small, the scrap may get lost [will have
  76.         to be shot]. This can be quite frustrating to the user.
  77.         
  78.     4.    The previous items have concentrated on topics that tend to cause an
  79.         increase in the minimum size to request from MultiFinder. On the flip
  80.         side, however, should be the consideration of what environments the
  81.         application may be running in. There may be a high probability that
  82.         many users with relatively small memory configurations will want to
  83.         avail themselves of your application. Or, many users might want to use it
  84.         while several other, possibly related/complementary applications are
  85.         running. If that is the case, it would be helpful to have a fairly
  86.         small minimum size.
  87.     
  88.     What we did for TEStyleSample:
  89.     
  90.         We determined the smallest heap size that TEStyleSample could have and still
  91.         run (22K). For the preferred size we added enough space to permit:
  92.             a. a maximum size TextEdit text handle (32000 characters)
  93.             b. a maximum usable TextEdit scrap (32000 characters)
  94.             b. a maximum scrap as a result of Copy (32000 characters)
  95.             d. a little performance cushion (see 2, above) (10K)
  96.         Result: 122K for preferred size
  97.         
  98.         For the minimum size we took the 22K and then scaled down our requirements
  99.         for a,b, and c above. We thought that providing 16K more would be lean
  100.         and mean (see 4, above).
  101.         Result: 38K for minimum size
  102. */
  103.  
  104. #define kPrefSize                512
  105. #define kMinSize                512
  106.     
  107. /* The following constants are used to identify menus and their items. The menu IDs
  108.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  109. #define    mApple                    128        /* Apple menu */
  110. #define    iAbout                    1
  111.  
  112. #define    mFile                    129        /* File menu */
  113. #define    iNew                    1
  114. #define    iOpen                    2
  115. #define    iClose                    4
  116. #define    iSave                    5
  117. #define    iSaveAs                    6
  118. #define    iQuit                    12
  119.  
  120. #define    mEdit                    130        /* Edit menu */
  121. #define    iUndo                    1
  122. #define    iCut                    3
  123. #define    iCopy                    4
  124. #define    iPaste                    5
  125. #define    iClear                    6
  126. #define iSelectAll                8
  127.  
  128. #define mFont                    131        /* Font menu         */
  129.  
  130. #define mFontSize                132        /* Font Size menu     */
  131.  
  132. #define mStyle                    133        /* Style menu         */
  133. #define iPlain                    1
  134. #define iBold                    3
  135. #define iItalic                    4
  136. #define iUnderline                5
  137. #define iOutline                6
  138. #define iShadow                    7
  139.  
  140. /* kTopLeft - This is for positioning the Disk Initialization dialogs. */
  141.  
  142. #define kDITop                    0x0050
  143. #define kDILeft                    0x0070
  144.  
  145. /*    kTextMargin is the number of pixels we leave blank at the edge of the window. */
  146. #define kTextMargin                2
  147.  
  148. /* kMaxOpenDocuments is used to determine whether a new document can be opened
  149.    or created. We keep track of the number of open documents, and disable the
  150.    menu items that create a new document when the maximum is reached. If the
  151.    number of documents falls below the maximum, the items are enabled again. */
  152. #define    kMaxOpenDocuments        1
  153.     
  154. /*    kMaxDocWidth is an arbitrary number used to specify the width of the TERec's
  155.     destination rectangle so that word wrap and horizontal scrolling can be
  156.     demonstrated. */
  157. #define    kMaxDocWidth            576
  158.     
  159. /* kMinDocDim is used to limit the minimum dimension of a window when GrowWindow
  160.     is called. */
  161. #define    kMinDocDim                64
  162.  
  163. /*    kControlInvisible is used to 'turn off' controls (i.e., cause the control not
  164.     to be redrawn as a result of some Control Manager call such as SetCtlValue)
  165.     by being put into the contrlVis field of the record. kControlVisible is used
  166.     the same way to 'turn on' the control. */
  167. #define kControlInvisible        0
  168. #define kControlVisible            0xFF
  169.  
  170. /*    kScrollbarAdjust and kScrollbarWidth are used in calculating
  171.     values for control positioning and sizing. */
  172. #define kScrollbarWidth            16
  173. #define kScrollbarAdjust        (kScrollbarWidth - 1)
  174.  
  175. /*    kScrollTweek compensates for off-by-one requirements of the scrollbars
  176.  to have borders coincide with the growbox. */
  177. #define kScrollTweek            2
  178.     
  179. /*    kCrChar is used to match with a carriage return when calculating the
  180.     number of lines in the TextEdit record. kDelChar is used to check for
  181.     delete in keyDowns. */
  182. #define kCrChar                    13
  183. #define kDelChar                8
  184.     
  185. /*    kButtonScroll is how many pixels to scroll horizontally when the button part
  186.     of the horizontal scrollbar is pressed. */
  187. #define kButtonScroll            4
  188.     
  189. /*    kMaxTELength is an arbitrary number used to limit the length of text in the TERec
  190.     so that various errors won't occur from too many characters in the text. */
  191. #define    kMaxTELength            32000
  192.  
  193. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  194.    SysEnvRec we understand. */
  195. #define    kSysEnvironsVersion        1
  196.  
  197. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  198.    by MultiFinder. Once we determine that an event is an OSEvent, we look at the
  199.    high byte of the message sent to determine which kind it is. To differentiate
  200.    suspend and resume events we check the resumeMask bit. */
  201. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  202. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  203. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  204. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  205.  
  206. /* kMinHeap - This is the minimum result from the following
  207.      equation:
  208.             
  209.             ORD(GetApplLimit) - ORD(ApplicZone)
  210.             
  211.      for the application to run. It will insure that enough memory will
  212.      be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  213.      application, and still give the application some 'breathing room'.
  214.      To derive this number, we ran under a MultiFinder partition that was
  215.      our requested minimum size, as given in the 'SIZE' resource. */
  216.      
  217. #define    kMinHeap                 (29 * 1024)
  218.     
  219. /* kMinSpace - This is the minimum result from PurgeSpace, when called
  220.      at initialization time, for the application to run. This number acts
  221.      as a double-check to insure that there really is enough memory for the
  222.      application to run, including what has been taken up already by
  223.      pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  224.      
  225. #define    kMinSpace                (20 * 1024)
  226.  
  227. /*    kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  228. #define kExtremeNeg                -32768
  229. #define kExtremePos                (32767 - 1) /* required to address an old region bug */
  230.     
  231. /* kTESlop provides some extra security when pre-flighting edit commands. */
  232. #define    kTESlop                    1024
  233.  
  234. /* The following are indicies into STR# resources. */
  235. #define    eWrongMachine            1
  236. #define    eSmallSize                2
  237. #define    eNoMemory                3
  238. #define    eNoSpaceCut                4
  239. #define    eNoCut                    5
  240. #define    eNoCopy                    6
  241. #define    eExceedPaste            7
  242. #define    eNoSpacePaste            8
  243. #define    eNoWindow                9
  244. #define    eExceedChar                10
  245. #define    eNoPaste                11
  246.  
  247. #define    rMenuBar        128                /* application's menu bar */
  248. #define    rAboutAlert        128                /* about alert */
  249. #define    rUserAlert        129                /* user error alert */
  250. #define    rFontSelect        130                /* Font Size selector dialog */
  251. #define    rDocWindow        128                /* application's window */
  252. #define    rVScroll        128                /* vertical scrollbar control */
  253. #define    rHScroll        129                /* horizontal scrollbar control */
  254. #define    kErrStrings        128                /* error string list */
  255. #define kFileMessageID    131
  256. #define kTextRunsDispID    134
  257.  
  258. /* defines for the disable/enable flags */
  259. /* use these for easier reading            */
  260.  
  261. #define AllItems    0b1111111111111111111111111111111
  262. #define NoItems        0b0000000000000000000000000000000    
  263. #define MenuItem2    0b0000000000000000000000000000010    
  264. #define MenuItem12    0b0000000000000000000100000000000    
  265.  
  266.